<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :dictMap="dictMapAsync"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
    ></Ht-search-form>

    <ht-table
      ref="dataTable"
      :multi-select="false"
      :showSerialNumber="false"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :reqConfig="regConfig"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="50" fixed="right">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog :title="title" center  :visible.sync="open" width="1024px" append-to-body :close-on-click-modal="false">
      <el-form ref="detailForm" :model="detailForm" label-width="120px" :disabled="true">
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原系统流水号" prop="id">
              <el-input v-model="detailForm.id" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="工作日期" prop="workdate">
              <el-date-picker v-model="detailForm.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="来往标识" prop="drct">
              <el-select style="width: 100%" v-model="detailForm.drct" placeholder="来往标识">
                <el-option
                  v-for="dict in dictMap.DRCTCODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原报文标识号" prop="oriPkgId">
              <el-input v-model="detailForm.oriPkgId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原报文类型" prop="reeChgInfo">
              <el-select
                style="width: 100%"
                v-model="
                  detailForm.oriMsgType === null || detailForm.oriMsgType === undefined
                    ? ''
                    : detailForm.oriMsgType + '-' + detailForm.oriMsgTypeDesc
                "
                placeholder="原业务类型"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原发起参与机构" prop="oriSender">
              <el-input v-model="detailForm.oriSender" />
            </el-form-item>
          </el-col>

          <el-col :span="12" v-if="this.detailForm.ccms320Drct === '1'">
            <el-form-item label="报文发送时间" prop="ccms320SndTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.ccms320SndTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="this.detailForm.ccms320Drct === '2'">
            <el-form-item label="报文接收时间" prop="ccms320RcvTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.ccms320RcvTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <div v-if="this.detailForm.sysCode === 'HVPS'">
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原发起间接参与机构" prop="oriIndirectSender">
                <el-input v-model="detailForm.oriIndirectSender" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原接收间接参与机构" prop="oriIndirectRecver">
                <el-input v-model="detailForm.oriIndirectRecver" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原明细标识号" prop="oriDtlNo">
                <el-input v-model="detailForm.oriDtlNo" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原业务类型编码" prop="reeChgInfo">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.oriBizType === null || detailForm.oriBizType === undefined
                      ? ''
                      : detailForm.oriBizType + '-' + detailForm.oriBizTypeDesc
                  "
                  placeholder="原业务类型"
                  :disabled="true"
                ></el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="待查询业务货币符号" prop="amountcurcd">
              <el-input v-model="detailForm.amountcurcd" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="待查询业务金额" prop="amount">
              <ht-amount-input
                v-model="detailForm.amount"
                placeholder="待查询业务金额"
                :disable="true"
              ></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="应答系统流水号" prop="answerId">
              <el-input v-model="detailForm.answerId" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="入账状态" prop="transStatus">
              <el-select
                style="width: 100%"
                v-model="
                  detailForm.transStatus === null || detailForm.transStatus === undefined
                    ? ''
                    : detailForm.transStatus + '-' + detailForm.transStatusDesc
                "
                placeholder="入账状态"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退汇原因" prop="reeChgInfo">
              <el-select
                style="width: 100%"
                v-model="
                  detailForm.reeChgInfo === null || detailForm.reeChgInfo === undefined
                    ? ''
                    : detailForm.reeChgInfo + '-' + detailForm.reeChgInfoDesc
                "
                placeholder="退汇原因"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="处理信息" prop="procInfo">
              <el-input v-model="detailForm.procInfo" />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="this.detailForm.ccms321Drct === '1'">
            <el-form-item label="报文发送时间" prop="ccms321SndTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.ccms321SndTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="this.detailForm.ccms321Drct === '2'">
            <el-form-item label="报文接收时间" prop="ccms321RcvTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.ccms321RcvTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { apiUrlConfigQuery, ccmsBusinessAccountQueryDetail } from "@/api/cnaps/ccms/320";
import { listPageMixin } from "@/libs/listPageMixin";
import { amountThousandsFormatter } from "@/utils/table_col_formatter";
import HtAmountInput from "@/views/components/HtAmountInput";
export default {
  name: "CcmsBusinessAccountQuery",
  mixins: [listPageMixin],
  components: { HtAmountInput },
  data() {
    return {
      // 查询参数
      queryParams: {
        workdate: "",
        workdate2: "",
        drct: "",
        transStatus: "",
      },
      // 搜索
      formOptions: [],
      //
      searchFormDictList: ["DRCTCODE", "TRANS_TYPE", "REE_CHG_INFO"],
      // 列信息
      regConfig: apiUrlConfigQuery,
      tableBindColumns: [
        { prop: "id", label: "原系统流水号", width: 180 },
        { prop: "workdate", label: "工作日期", type: "date" },
        { prop: "drct", label: "报文320来往账标志", dictCode: "DRCTCODE", width: 180 },
        { prop: "oriPkgId", label: "原报文标识号", width: 120 },
        { prop: "oriSender", label: "原发起参与机构", width: 180 },
        {
          prop: "oriMsgType",
          label: "原报文类型",
          formatter(row, text, index) {
            return (
              (row["oriMsgType"] === null || row["oriMsgType"] === undefined ? "" : row["oriMsgType"]) +
              "-" +
              (row["oriMsgTypeDesc"] === null || row["oriMsgTypeDesc"] === undefined ? "" : row["oriMsgTypeDesc"])
            );
          },
          width: 300,
        },
        {
          prop: "amount",
          label: "待查询业务金额",
          type: "price",
          width: 180,
        },
        { prop: "transStatus", label: "入账状态", dictCode: "TRANS_TYPE", width: 120 },
        { prop: "reeChgInfo", label: "退汇原因", dictCode: "REE_CHG_INFO", width: 300 },
        { prop: "procInfo", label: "处理信息", width: 120 },
      ],
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {
        amount: 0.0,
      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          size: "small",
          label: "原系统流水号",
          placeholder: "请输入原系统流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dict",
        dict: "DRCTCODE",
        prop: "drct",
        defaultAttr: {
          size: "small",
          label: "来往账标志",
          placeholder: "请输入来往账标志",
        },
      },

      {
        type: "dict",
        dict: "TRANS_TYPE",
        prop: "transStatus",
        defaultAttr: {
          size: "small",
          label: "入账状态",
          placeholder: "请输入入账状态",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "业务入账状态查询明细";
      ccmsBusinessAccountQueryDetail(row).then((response) => {
        this.resetForm("detailForm");
        this.detailForm = response.result;
        this.open = true;
      });
    },
  },
};
</script>
